package cn.ahaiahaixx.converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import cn.ahaiahaixx.utils.MyUtils;

/**
 * 整数类型转换器
 * 
 * @author Aiden Pearce
 *
 */
@Component
public class IntegerConverter implements Converter<String, Integer> {

	@Override
	public Integer convert(String source) {
		if (MyUtils.isEmpty(source)) {
			return null;
		}
		source = MyUtils.trim(source);
		try {
			return Integer.parseInt(source);
		} catch (Exception e) {

		}
		return null;
	}
}
